import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { dictItemCheck } from './dict.api';
import { rules } from '/@/utils/helper/validator';
import { h } from 'vue';
import { render } from '/@/utils/common/renderUtils';
import { voteFindAll } from './article.api';
import { UploadTypeEnum } from '/@/components/Form/src/jeecg/components/JUpload';

export const columns: BasicColumn[] = [
  {
    title: '标题',
    dataIndex: 'title',
    width: 240,
  },
  {
    title: '内容',
    dataIndex: 'content',
    width: 240,
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    label: '标题',
    field: 'title',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    label: '内容',
    field: 'content',
    component: 'Input',
    colProps: { span: 6 },
  },
];

export const formSchema: FormSchema[] = [
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
  {
    label: '头部图',
    field: 'title',
    required: true,
    component: 'JImageUpload',
    componentProps: {
      fileMax: 1,
    },
  },
  {
    label: '投票项目',
    field: 'pollId',
    required: true,
    component: 'ApiSelect',
    componentProps: {
      api: voteFindAll,
      labelField: 'name',
      valueField: 'id',
    },
  },
  {
    label: '轮播图文件',
    field: 'imgUrlList',
    component: 'JUpload',
    componentProps: { maxCount: 5, fileType: UploadTypeEnum.image },
  },
  {
    label: '内容',
    field: 'content',
    component: 'Input',
    render: render.renderTinymce,
  },
];
